<template>
  <el-container class="home-container">
    <el-header>
      <div class="left-logo">
        <img src="@/assets/logo.png"/>
        <span>
          <h3>停车场管理系统</h3>
        </span>
      </div>
      <div style="text-align: right;width: 50%;padding-right: 25px;">
        欢迎[管理员]：{{userInfo.nike}} 欢迎您！
      </div>
      <el-button type="danger" icon="iconfont icon-r-left" @click="logout"> 退出登录</el-button>
    </el-header>
    <el-container>
      <el-aside width="200px">
        <el-menu
            background-color="white"
            text-color="black"
            active-text-color="grey"
            :unique-opened="true"
            :collapse-transition="false"
            router
            :default-active="activePath"
        >
          <!-- 菜单 -->
          <el-menu-item
              :index="item.path + ''"
              v-for="item in menuList"
              :key="item.id"
              @click="savePath('/' + item.path)"
          >
            <template slot="title">
              <i :class="item.icon" style="font-size: 28px;color: black;"></i>
              <span><b style="font-size: 18px;"> {{ item.name }}</b></span>
            </template>
          </el-menu-item>
        </el-menu>
      </el-aside>
      <el-main>
        <router-view/>
      </el-main>
    </el-container>
  </el-container>

</template>

<script>
export default {
  name: "Mane",
  data() {
    return {
      // 菜单列表
      menuList: [
        {
          name: "首页",
          id: 101,
          path: "maneHome",
          icon: "iconfont icon-r-home",
        },
        {
          name: "用户信息管理",
          id: 111,
          path: "userMane",
          icon: "iconfont icon-r-user1",
        },
        {
          name: "车位信息管理",
          id: 131,
          path: "carmaneger",
          icon: "iconfont icon-r-building",
        },
        {
          name: "车位费用设置",
          id: 141,
          path: "money",
          icon: "iconfont icon-r-shield",
        },
        {
          name: "停泊车辆查询",
          id: 151,
          path: "stallMane",
          icon: "iconfont icon-r-find",
        },
        {
          name: "车辆进出管理",
          id: 161,
          path: "carInMane",
          icon: "iconfont icon-r-right",
        },
        {
          name: "登录日志查询",
          id: 171,
          path: "loginInfoMane",
          icon: "iconfont icon-r-paper",
        },
      ],
      userInfo: JSON.parse(sessionStorage.getItem('admin')) || {}, // 用户信息
      activePath: "/users", // 当前路由
    }
  },
  methods: {
    logout() {
      sessionStorage.removeItem('admin')
      this.$message({
        message: "退出成功",
        type: "success",
        duration:1000,
        onClose: () => {
          this.$router.push("/")
        }
      })
    },
    savePath(path) {
      //this.activePath = path
    },
  }

}
</script>

<style scoped>
.home-container {
  height: 100vh;
}

.el-header {
  background-color: white;
  display: flex;
  justify-content: space-between;
  padding-left: 0;
  align-items: center;
  color: black;
  font-size: 20px;
  border-bottom: 1px solid grey;
}

.left-logo {
  height: 100%;
  display: flex;
  align-items: center;
}

.left-logo > span {
  margin-left: 15px;
}

.left-logo > img {
  height: 50%;
  margin-left: 25px;
}

.el-aside {
  background-color: white;
}

.el-main {
  background-color: #eaedf1;
}

.el-menu {
  border-right: none;
}

.fa {
  margin-right: 10px;
}

.toggle-button {
  background-color: #4a5064;
  font-size: 10px;
  line-height: 24px;
  color: #fff;
  text-align: center;
  letter-spacing: 0.2em;
  cursor: pointer;
}
</style>
